package com.cjhedu.web.service.impl;

import com.cjhedu.web.domain.Dept;
import com.cjhedu.web.mapper.DeptMapper;
import com.cjhedu.web.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 陈佳豪
 * @version 1.0
 */
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;

    @Override
    public List<Dept> getAll() {
        //int i = 1/0;
        //System.out.println(i);
        return deptMapper.getAll();
    }

    @Override
    public int del(Integer id) {
        return deptMapper.del(id);
    }

    @Override
    public int add(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        return deptMapper.add(dept);
    }

    @Override
    public int update(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        return deptMapper.update(dept);
    }

}
